package com.example.basecore.factory;

import com.example.basecore.command.CommandInterceptor;
import com.example.basecore.dto.Command;

import java.util.Map;
import java.util.Set;

/**
 * @author ycd0075
 * @date 2024-01-25 22:33
 */
public class CommandInterceptorFactory {

    private Map<Class<? extends Command>, Set<CommandInterceptor>> interceptors;

    public CommandInterceptorFactory(Map<Class<? extends Command>, Set<CommandInterceptor>> interceptors) {
        this.interceptors = interceptors;
    }

    public Set<CommandInterceptor> create(Command command) {
        return interceptors.get(command.getClass());
    }
}
